#include "imageinfo.h"

ImageInfo::ImageInfo() {}

bool ImageInfo::WriteXML( QXmlStreamWriter &writer){
    writer.writeStartElement("ImageInfo");
    writer.writeTextElement("ImageWidth",QString::number(m_nImageWidth));
    writer.writeTextElement("ImageHeight",QString::number(m_nImageHeight));
    writer.writeTextElement("ImageChannel",QString::number(m_nImageChannel));
    writer.writeEndElement();
    return true;
}

bool ImageInfo::ReadXML(QXmlStreamReader &reader){
    QXmlStreamAttributes attributes = reader.attributes();

    QXmlStreamReader::TokenType token = reader.readNext();
    while (!(reader.tokenType() == QXmlStreamReader::EndElement &&
             reader.name() == QStringLiteral("ImageInfo"))) {

        if (reader.name() == QStringLiteral("ImageWidth")) {
            m_nImageWidth = reader.readElementText().toInt();
        }else if (reader.name() == QStringLiteral("ImageHeight")) {
            m_nImageHeight = reader.readElementText().toInt();
        }else if (reader.name() == QStringLiteral("ImageChannel")) {
            m_nImageChannel = reader.readElementText().toInt();
        }

        reader.readNext();
    }
    return true;
}
